package cn.angleline.cloudhub.easbi

import com.google.common.cache.Cache
import com.google.common.cache.CacheBuilder
import okhttp3.OkHttpClient
import okhttp3.logging.HttpLoggingInterceptor
import org.springframework.beans.factory.annotation.Autowired
import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
import org.springframework.context.annotation.Bean
import org.springframework.data.domain.PageRequest
import org.springframework.scheduling.annotation.EnableScheduling
import java.math.RoundingMode
import java.util.concurrent.TimeUnit

@SpringBootApplication
@EnableScheduling
class EasBiApplication {


    @Bean(name = ["tokenCache"])
    fun tokenCache(): Cache<String, String> {
        return CacheBuilder.newBuilder()
                .expireAfterWrite(7200, TimeUnit.SECONDS)
                .initialCapacity(1)
                .build()
    }

    @Bean
    fun okHttpClient(): OkHttpClient {
        val builder = OkHttpClient.Builder()
        val httpLoggingInterceptor = HttpLoggingInterceptor()
        httpLoggingInterceptor.level = HttpLoggingInterceptor.Level.NONE
        builder.addInterceptor(httpLoggingInterceptor)
        return builder.build()
    }
}

fun main(args: Array<String>) {
    runApplication<EasBiApplication>(*args)
}




